// source --> https://alu-akces.com.pl/wp-content/plugins/top-bar/inc/../js/tpbr_front.js?ver=5.5.4 /** * Top Bar Front JS */ ;(function($){ $(document).ready(function (){ /* Stylesheet JS handling */ var sheet = (function() { var style = document.createElement("style"); style.appendChild(document.createTextNode("")); document.head.appendChild(style); return style.sheet; })(); function addCSSRule(sheet, selector, rules, index) { if("insertRule" in sheet) { sheet.insertRule(selector + "{" + rules + "}", index); } else if("addRule" in sheet) { sheet.addRule(selector, rules, index); } } /* Debounce function (credit: David Walsh). */ function debounce(func, wait, immediate) { var timeout; return function() { var context = this, args = arguments; var later = function() { timeout = null; if (!immediate) func.apply(context, args); }; var callNow = immediate && !timeout; clearTimeout(timeout); timeout = setTimeout(later, wait); if (callNow) func.apply(context, args); }; }; /* Throttle function (credit: Niall Campbell). */ function throttle(func, wait, immediate) { var timeout; return function() { var context = this, args = arguments; var later = function() { timeout = null; if (!immediate) func.apply(context, args); }; var callNow = immediate && !timeout; if ( !timeout ) timeout = setTimeout( later, wait ); if (callNow) func.apply(context, args); }; }; /* Top Bar settings. */ for (var property in tpbr_settings) { if (tpbr_settings.hasOwnProperty(property)) { eval("var " + property + " = " + "'" + tpbr_settings[property] + "'" ); } } /* Top Bar is inactive, quit. */ if (status == 'inactive') { return false; } /* Variable initialization. */ var barPosition = fixed; var secondaryColor = ''; var barBackgroundColor = color; /* Checks if user can see the bar. */ function userCanSeeBar() { // Only guests can see the bar. if (user_who == 'notloggedin' && guests_or_users == 'guests') { return true; } // Only users can see the bar. if ( user_who == 'loggedin' && guests_or_users == 'users' ){ return true; } // Everyone can see the bar. if (guests_or_users == 'all') { return true } // Else. return false; } if (!userCanSeeBar()) { return; } /* Generates a scondary color. */ function shadeColor1(color, percent) { var num = parseInt(color.slice(1),16), amt = Math.round(2.55 * percent), R = (num >> 16) + amt, G = (num >> 8 & 0x00FF) + amt, B = (num & 0x0000FF) + amt; return "#" + (0x1000000 + (R<255?R<1?0:R:255)*0x10000 + (G<255?G<1?0:G:255)*0x100 + (B<255?B<1?0:B:255)).toString(16).slice(1); } secondaryColor = shadeColor1(barBackgroundColor, -12); /* Gets the button element to add to the bar. */ function getButtonElement() { var target = (button_behavior == 'newwindow') ? 'target="_blank"' : ''; if (yn_button == 'button' && button_text) { // Gets secondary color. return '' + button_text + ''; } else { return ''; } } /* Initialize the bar. */ function initBar() { // Gets button element. buttonElement = getButtonElement(); /* Bar is fixed top. */ if (barPosition == 'fixed'){ var barPositionStyles = 'position:fixed; z-index:99998; width:100%; left:0px; top:0px;'; var barElement = '
' + message + buttonElement + '
'; } else { var barElement = '
' + message + buttonElement + '
'; } /* Injects the bar. */ setTimeout(function(){ $(barElement).prependTo('body').show(); initBarPosition(); }); } /* initial call. */ initBar(); /* Sets bar to initial position. */ function initBarPosition() { // Variables. var newAdminBarHeight = $('#wpadminbar').outerHeight(); var newHeight = ($('#tpbr_topbar').css('display') == 'none') ? 0 : $('#tpbr_topbar').outerHeight(); var adminBarPosition = $("#wpadminbar").css('position'); var bodyScroll = $(document).scrollTop(); var pushVariation = 0; var barNewTop = 0; // Bar is fixed top. if (barPosition == 'fixed') { if(is_admin_bar) { if( adminBarPosition != 'fixed' ) { if (bodyScroll < newAdminBarHeight) { $("#tpbr_topbar").css('top', newAdminBarHeight - bodyScroll ); pushVariation = newAdminBarHeight - bodyScroll; barNewTop = newAdminBarHeight - bodyScroll; } else { $("#tpbr_topbar").css('top', 0 ); pushVariation = 0; barNewTop = 0; } } else { $("#tpbr_topbar").css('top', newAdminBarHeight ); pushVariation = 0; barNewTop = newAdminBarHeight; } } else { $("#tpbr_topbar").css('top', 0 ); } /* Update the pusher. */ $('.pushr').height(newHeight); // Bar is in standard position. } else { if(is_admin_bar) { if( adminBarPosition == 'fixed' ) { if (bodyScroll < newHeight) { pushVariation = newHeight - bodyScroll; } else { pushVariation = 0; } } else { if (bodyScroll < newAdminBarHeight + newHeight) { pushVariation = newAdminBarHeight + newHeight - bodyScroll; } else { pushVariation = 0; } } } else { if (bodyScroll < newHeight) { pushVariation = newHeight - bodyScroll; } else { pushVariation = 0; } } $("#tpbr_topbar").css('top', 0 ); } // Fix bar position based on context. if (detect_sticky == 1) { updateBarContext(newAdminBarHeight, newHeight, adminBarPosition, pushVariation, bodyScroll); } } /* Blends the bar in context. */ var initialEls = []; var firstTime = 0; function updateBarContext(newAdminBarHeight, newHeight, adminBarPosition, pushVariation, bodyScroll) { if (sheet.cssRules) { // all browsers, except IE before version 9 for (var i=0; i 0) { for (var h=0; h